package com.tedu.lingmaagent.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tedu.lingmaagent.domain.Appointment;
import com.tedu.lingmaagent.mapper.AppointmentMapper;
import com.tedu.lingmaagent.service.AppointmentService;
import org.springframework.stereotype.Service;

@Service
public class AppointmentServiceImpl extends ServiceImpl<AppointmentMapper, Appointment> implements AppointmentService {
    @Override
    public Appointment queryAppointment(String card) {
        LambdaQueryWrapper<Appointment> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Appointment::getIdCard,card);
        Appointment appointment=super.getOne(queryWrapper);
        return appointment;
    }

    @Override
    public boolean cancelAppointment(String idCard, String date, String time, String department) {
        LambdaQueryWrapper<Appointment> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Appointment::getIdCard, idCard)
                .eq(Appointment::getDate, date)
                .eq(Appointment::getTime, time)
                .eq(Appointment::getDepartment, department);
        int rows = baseMapper.delete(wrapper);
        return rows > 0;
    }
}

